home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / IRDA / IRLAP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  231 lines

  1. /*********************************************************************
  2.  *                
  3.  * Filename:      irlap.h
  4.  * Version:       0.8
  5.  * Description:   An IrDA LAP driver for Linux
  6.  * Status:        Experimental.
  7.  * Author:        Dag Brattli <dagb@cs.uit.no>
  8.  * Created at:    Mon Aug  4 20:40:53 1997
  9.  * Modified at:   Fri Mar 26 15:15:17 1999
  10.  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  11.  * 
  12.  *     Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
  13.  *     
  14.  *     This program is free software; you can redistribute it and/or 
  15.  *     modify it under the terms of the GNU General Public License as 
  16.  *     published by the Free Software Foundation; either version 2 of 
  17.  *     the License, or (at your option) any later version.
  18.  *
  19.  *     Neither Dag Brattli nor University of Troms° admit liability nor
  20.  *     provide warranty for any of this software. This material is 
  21.  *     provided "AS-IS" and at no charge.
  22.  *
  23.  ********************************************************************/
  24.  
  25. #ifndef IRLAP_H
  26. #define IRLAP_H
  27.  
  28. #include <linux/config.h>
  29. #include <linux/types.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/netdevice.h>
  32. #include <linux/ppp_defs.h>
  33. #include <linux/ppp-comp.h>
  34.  
  35. #include <net/irda/irlap_event.h>
  36.  
  37. #define LAP_RELIABLE   1
  38. #define LAP_UNRELIABLE 0
  39.  
  40. #define LAP_ADDR_HEADER 1  /* IrLAP Address Header */
  41. #define LAP_CTRL_HEADER 1  /* IrLAP Control Header */
  42. #define LAP_COMP_HEADER 1  /* IrLAP Compression Header */
  43.  
  44. #ifdef CONFIG_IRDA_COMPRESSION
  45. #  define LAP_HEADER  (LAP_ADDR_HEADER + LAP_CTRL_HEADER + LAP_COMP_HEADER)
  46. #  define IRDA_COMPRESSED 1
  47. #  define IRDA_NORMAL     0
  48. #else
  49. #define LAP_HEADER (LAP_ADDR_HEADER + LAP_CTRL_HEADER)
  50. #endif
  51.  
  52. #define BROADCAST  0xffffffff /* Broadcast device address */
  53. #define CBROADCAST 0xfe       /* Connection broadcast address */
  54. #define XID_FORMAT 0x01       /* Discovery XID format */
  55.  
  56. #define LAP_WINDOW_SIZE 8
  57. #define MAX_CONNECTIONS 1
  58.  
  59. #define NR_EXPECTED     1
  60. #define NR_UNEXPECTED   0
  61. #define NR_INVALID     -1
  62.  
  63. #define NS_EXPECTED     1
  64. #define NS_UNEXPECTED   0
  65. #define NS_INVALID     -1
  66.  
  67. #ifdef CONFIG_IRDA_COMPRESSION
  68. /*  
  69.  *  Just some shortcuts (may give you strange compiler errors if you change 
  70.  *  them :-)
  71.  */
  72. #define irda_compress    (*self->compessor.cp->compress)
  73. #define irda_comp_free   (*self->compressor.cp->comp_free)
  74. #define irda_decompress  (*self->decompressor.cp->decompress)
  75. #define irda_decomp_free (*self->decompressor.cp->decomp_free)
  76. #define irda_incomp      (*self->decompressor.cp->incomp)
  77.  
  78. struct irda_compressor {
  79.     QUEUE queue;
  80.  
  81.     struct compressor *cp;
  82.     void *state; /* Not used by IrDA */
  83. };
  84. #endif
  85.  
  86. /* Main structure of IrLAP */
  87. struct irlap_cb {
  88.     QUEUE q; /* Must be first */
  89.  
  90.     int magic;
  91.  
  92.     struct irda_device *irdev;
  93.     struct device      *netdev;
  94.  
  95.     /* Connection state */
  96.     volatile IRLAP_STATE state;       /* Current state */
  97.  
  98.     /* Timers used by IrLAP */
  99.     struct timer_list query_timer;
  100.     struct timer_list slot_timer;
  101.     struct timer_list discovery_timer;
  102.     struct timer_list final_timer;
  103.     struct timer_list poll_timer;
  104.     struct timer_list wd_timer;
  105.     struct timer_list backoff_timer;
  106.  
  107.     /* Timeouts which will be different with different turn time */
  108.     int slot_timeout;
  109.     int poll_timeout;
  110.     int final_timeout;
  111.     int wd_timeout;
  112.  
  113.     struct sk_buff_head tx_list;  /* Frames to be transmitted */
  114.  
  115.      __u8    caddr;        /* Connection address */
  116.     __u32   saddr;        /* Source device address */
  117.     __u32   daddr;        /* Destination device address */
  118.  
  119.     int     retry_count;  /* Times tried to establish connection */
  120.     int     add_wait;     /* True if we are waiting for frame */
  121.  
  122.     __u8    connect_pending;
  123.     __u8    disconnect_pending;
  124.  
  125.     /*  To send a faster RR if tx queue empty */
  126. #ifdef CONFIG_IRDA_FAST_RR
  127.     int     fast_RR_timeout;
  128.     int     fast_RR;      
  129. #endif
  130.     
  131.     int N1; /* N1 * F-timer = Negitiated link disconnect warning threshold */
  132.     int N2; /* N2 * F-timer = Negitiated link disconnect time */
  133.     int N3; /* Connection retry count */
  134.  
  135.     int     local_busy;
  136.     int     remote_busy;
  137.     int     xmitflag;
  138.  
  139.     __u8    vs;           /* Next frame to be sent */
  140.     __u8    vr;           /* Next frame to be received */
  141.     int     tmp;
  142.     __u8    va;           /* Last frame acked */
  143.      int     window;       /* Nr of I-frames allowed to send */
  144.     int     window_size;  /* Current negotiated window size */
  145.     int     window_bytes; /* Number of bytes allowed to send */
  146.     int     bytes_left;   /* Number of bytes allowed to transmit */
  147.  
  148.     struct sk_buff_head wx_list;
  149.  
  150.     __u8    ack_required;
  151.     
  152.     /* XID parameters */
  153.      __u8    S;           /* Number of slots */
  154.     __u8    slot;        /* Random chosen slot */
  155.      __u8    s;           /* Current slot */
  156.     int     frame_sent;  /* Have we sent reply? */
  157.  
  158.     int discovery_count;
  159.     hashbin_t *discovery_log;
  160.      discovery_t *discovery_cmd;
  161.  
  162.     struct qos_info qos_tx;    /* QoS requested by peer */
  163.     struct qos_info qos_rx;    /* QoS requested by self */
  164.  
  165.     struct notify_t notify; /* Callbacks to IrLMP */
  166.  
  167.     int    mtt_required;  /* Minumum turnaround time required */
  168.     int    xbofs_delay;   /* Nr of XBOF's used to MTT */
  169.     int    bofs_count;    /* Negotiated extra BOFs */
  170.  
  171.      struct irda_statistics stats;
  172.  
  173. #ifdef CONFIG_IRDA_COMPRESSION
  174.     struct irda_compressor compressor;
  175.         struct irda_compressor decompressor;
  176. #endif
  177. };
  178.  
  179. extern hashbin_t *irlap;
  180.  
  181. /* 
  182.  *  Function prototypes 
  183.  */
  184.  
  185. int irlap_init( void);
  186. void irlap_cleanup( void);
  187.  
  188. struct irlap_cb *irlap_open( struct irda_device *dev);
  189. void irlap_close( struct irlap_cb *self);
  190.  
  191. void irlap_connect_request( struct irlap_cb *self, __u32 daddr, 
  192.                 struct qos_info *qos, int sniff);
  193. void irlap_connect_response( struct irlap_cb *self, struct sk_buff *skb);
  194. void irlap_connect_indication( struct irlap_cb *self, struct sk_buff *skb);
  195. void irlap_connect_confirm( struct irlap_cb *, struct sk_buff *skb);
  196.  
  197. inline void irlap_data_indication( struct irlap_cb *, struct sk_buff *);
  198. inline void irlap_unit_data_indication( struct irlap_cb *, struct sk_buff *);
  199. inline void irlap_data_request( struct irlap_cb *, struct sk_buff *, 
  200.                 int reliable);
  201.  
  202. void irlap_disconnect_request( struct irlap_cb *);
  203. void irlap_disconnect_indication( struct irlap_cb *, LAP_REASON reason);
  204.  
  205. void irlap_status_indication( int quality_of_link);
  206.  
  207. void irlap_test_request( __u8 *info, int len);
  208.  
  209. void irlap_discovery_request(struct irlap_cb *, discovery_t *discovery);
  210. void irlap_discovery_confirm(struct irlap_cb *, hashbin_t *discovery_log);
  211. void irlap_discovery_indication(struct irlap_cb *, discovery_t *discovery);
  212.  
  213. void irlap_reset_indication( struct irlap_cb *self);
  214. void irlap_reset_confirm(void);
  215.  
  216. void irlap_update_nr_received( struct irlap_cb *, int nr);
  217. int irlap_validate_nr_received( struct irlap_cb *, int nr);
  218. int irlap_validate_ns_received( struct irlap_cb *, int ns);
  219.  
  220. int  irlap_generate_rand_time_slot( int S, int s);
  221. void irlap_initiate_connection_state( struct irlap_cb *);
  222. void irlap_flush_all_queues( struct irlap_cb *);
  223. void irlap_change_speed( struct irlap_cb *, int);
  224. void irlap_wait_min_turn_around( struct irlap_cb *, struct qos_info *);
  225.  
  226. void irlap_init_qos_capabilities( struct irlap_cb *, struct qos_info *);
  227. void irlap_apply_default_connection_parameters( struct irlap_cb *self);
  228. void irlap_apply_connection_parameters( struct irlap_cb *, struct qos_info *);
  229.  
  230. #endif
  231.